package com.zhongyu.scheduler.consumer.service.impl;

import com.zhongyu.comm.pojo.SchedulerSeatPrice;
import com.zhongyu.scheduler.consumer.client.SchedulerSeatPriceClient;
import com.zhongyu.scheduler.consumer.service.SchedulerSeatPriceService;
import com.zhongyu.scheduler.consumer.vo.CinemaSeatVo;
import com.zhongyu.scheduler.consumer.vo.SchedulerSeatPriceVo;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Service("schedulerSeatPriceService")
public class SchedulerSeatPriceServiceImpl implements SchedulerSeatPriceService {


    @Resource
    private SchedulerSeatPriceClient schedulerSeatPriceClient;

    @Override
    public List<SchedulerSeatPriceVo> queryItemPrice(Integer scheduleId) {
       List<SchedulerSeatPrice> list=schedulerSeatPriceClient.findBySchedulerId(scheduleId);
     return   list.stream().map(schedulerSeatPrice -> {
           SchedulerSeatPriceVo vo=new SchedulerSeatPriceVo();
           BeanUtils.copyProperties(schedulerSeatPrice,vo);
         Integer seatNum=  schedulerSeatPrice.getSeatNum();
       vo.setIsHaveSeat(seatNum>0?1:0);
           return vo;
       }).collect(Collectors.toList());

    }


}
